#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{

    while(1)
    {
    pid_t id = fork();
    if(id < 0)
    {
        perror("fork failed\n");
    }   
    else if(id > 0)
    {   
        printf("id: %d, I am parent process, pid: %d, ppid: %d\n", id, getpid(), getppid());   
    }
    else
    {   
        printf("id: %d, I am child process, pid: %d, ppid: %d \n\n", id, getpid(), getppid());
    }       

    sleep(5);
    }

    return 0;
}

